package com.zlp.quartz.spring;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.time.LocalDateTime;

/**
 * @Author: zhulaiping
 * @Date: 2021/10/17 15:03
 */

@Configuration
@EnableScheduling
public class TaskDemo {

    //3.添加定时任务
    @Scheduled(cron = "0/5 * * * * ?")
    //或直接指定时间间隔，例如：5秒
    //@Scheduled(fixedRate=5000)
    private void configureTasks() {
        System.err.println(Thread.currentThread().getName()+"执行静态定时任务时间: " + LocalDateTime.now());
    }
}
